# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.FCMData.V1beta1.Model.GoogleFirebaseFcmDataV1beta1MessageOutcomePercents do
  @moduledoc """
  Percentage breakdown of message delivery outcomes. These categories are mutually exclusive. All percentages are calculated with countMessagesAccepted as the denominator. These categories may not account for all message outcomes.

  ## Attributes

  *   `collapsed` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were [collapsed](https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages) by another message.
  *   `delivered` (*type:* `number()`, *default:* `nil`) - The percentage of all accepted messages that were successfully delivered to the device.
  *   `droppedAppForceStopped` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were dropped because the application was force stopped on the device at the time of delivery and retries were unsuccessful.
  *   `droppedDeviceInactive` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were dropped because the target device is inactive. FCM will drop messages if the target device is deemed inactive by our servers. If a device does reconnect, we call [OnDeletedMessages()](https://firebase.google.com/docs/cloud-messaging/android/receive#override-ondeletedmessages) in our SDK instead of delivering the messages.
  *   `droppedTooManyPendingMessages` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that were dropped due to [too many undelivered non-collapsible messages](https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages). Specifically, each app instance can only have 100 pending messages stored on our servers for a device which is disconnected. When that device reconnects, those messages are delivered. When there are more than the maximum pending messages, we call [OnDeletedMessages()](https://firebase.google.com/docs/cloud-messaging/android/receive#override-ondeletedmessages) in our SDK instead of delivering the messages.
  *   `droppedTtlExpired` (*type:* `number()`, *default:* `nil`) - The percentage of accepted messages that expired because [Time To Live (TTL)](https://firebase.google.com/docs/cloud-messaging/concept-options#ttl) elapsed before the target device reconnected.
  *   `pending` (*type:* `number()`, *default:* `nil`) - The percentage of messages accepted on this day that were not dropped and not delivered, due to the device being disconnected (as of the end of the America/Los_Angeles day when the message was sent to FCM). A portion of these messages will be delivered the next day when the device connects but others may be destined to devices that ultimately never reconnect.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :collapsed => number() | nil,
          :delivered => number() | nil,
          :droppedAppForceStopped => number() | nil,
          :droppedDeviceInactive => number() | nil,
          :droppedTooManyPendingMessages => number() | nil,
          :droppedTtlExpired => number() | nil,
          :pending => number() | nil
        }

  field(:collapsed)
  field(:delivered)
  field(:droppedAppForceStopped)
  field(:droppedDeviceInactive)
  field(:droppedTooManyPendingMessages)
  field(:droppedTtlExpired)
  field(:pending)
end

defimpl Poison.Decoder,
  for: GoogleApi.FCMData.V1beta1.Model.GoogleFirebaseFcmDataV1beta1MessageOutcomePercents do
  def decode(value, options) do
    GoogleApi.FCMData.V1beta1.Model.GoogleFirebaseFcmDataV1beta1MessageOutcomePercents.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.FCMData.V1beta1.Model.GoogleFirebaseFcmDataV1beta1MessageOutcomePercents do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
